package com.cyk.user.config;

import java.util.Objects;

public class Resp<T> {

    protected int status;
    protected String message;
    private T data;

    public Resp(T data) {
        this.status = AppStatus.SUCCESS.apiCode;
        this.message = AppStatus.SUCCESS.commonMsg;
        this.data = data;
    }

    public static Resp success() {
        return new Resp(AppStatus.SUCCESS.apiCode, AppStatus.SUCCESS.commonMsg, (Object)null);
    }

    public static Resp error(AppStatus status) {
        return new Resp(status.apiCode, status.commonMsg, (Object)null);
    }

    public static Resp error(AppStatus status, String message) {
        return new Resp(status.apiCode, message, (Object)null);
    }

    public boolean isOk() {
        return AppStatus.SUCCESS.apiCode == this.status;
    }

    public int getStatus() {
        return this.status;
    }

    public String getMessage() {
        return this.message;
    }

    public T getData() {
        return this.data;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Resp)) {
            return false;
        } else {
            Resp<?> other = (Resp)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getStatus() != other.getStatus()) {
                return false;
            } else {
                Object this$message = this.getMessage();
                Object other$message = other.getMessage();
                if (this$message == null) {
                    if (other$message != null) {
                        return false;
                    }
                } else if (!this$message.equals(other$message)) {
                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof Resp;
    }

    @Override
    public int hashCode() {
        return Objects.hash(status, message, data);
    }

    public String toString() {
        return "Resp(status=" + this.getStatus() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
    }

    public Resp() {
    }

    public Resp(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

}
